const http = require('http')
const server = http.createServer()
server.on('request', (req, res) => {
  const url = new URL(req.url, 'http://localhost:3000/')
  res.writeHead(200, {
    //解决乱码问题
    "Content-Type": "text/html;charset=utf-8"
  })
  switch (url.pathname) {
    case '/index':
      res.end('index')
      break;

    default: res.end('404')
  }
})
server.listen(3000, () => {
  console.log('创建成功！')
})